﻿@using MyData.Dto
@model AdminUserDto
@{
    ViewBag.Title = "AdminUserView";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script src="~/Content/UI/js/select-ui.min.js"></script>
<script type="text/javascript">
    $(function () {
        $(".select3").uedSelect({
            width: 300
        });
    })


</script>
<form id="form1">
    <div class="tools">
        <ul class="toolbar">
            <li class="click" onclick="fnSave()"><span><img src="../Content/UI/images/t02.png" /></span>保存</li>
        </ul>
    </div>
    <div class="formbody">
        <ul class="forminfo">
            <li>
                <label>账号:</label><input value="@Model.UserName" name="UserName" type="text" class="dfinput" id="UserName"  required="required"/>
            </li>
            <li>
                <label>密码:</label><input value="@Model.PassWord"  name="PassWord" type="text" class="dfinput" id="PassWord" required="required" maxlength="8"/>
            </li>
            <li>
                <label>昵称:</label><input value="@Model.NickName" name="NickName" type="text" class="dfinput" id="NickName" required="required"  />
            </li>
            <li style="width:427px">
                <label>所属部门:</label>
                <div class="vocation" style="width:300px">
                    <select class="select3" id="DepartId">
                        @{
                            var departs = ViewBag.Departs as List<DepartDto>;
                            foreach (var item in departs)
                            {
                                <option value="@item.Id">@item.Name</option>
                            }
                        }
                    </select>
                </div>
            </li>
        </ul>
        <input type="hidden" id="Id" value="@Model.Id.ToString()" />
    </div>
</form>
<script type="text/javascript">
    function fnSave() {
        if ($('#form1').valid())
        {
            $.post("../AdminUser/SaveAdminUser", queryParams(), function (result) {
                if (result.state == 1) {
                    layer.msg('操作成功');
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index)
                    parent.$("#table").bootstrapTable('refresh');
                }
                else {
                    layer.msg(result.message);
                }
            })
        }
       
    }
    function queryParams() {
        return {
            UserName: $("#UserName").val(),
            PassWord: $("#PassWord").val(),
            NickName: $("#NickName").val(),
            DepartId:$("#DepartId").val(),
            Id: $("#Id").val()
        };
    }
</script>

